package com.hk.migration.cannal.process;

import com.alibaba.otter.canal.protocol.CanalEntry;
import com.hk.migration.cannal.CanalData;
import com.hk.migration.cannal.CanalProcess;
import com.hk.migration.cannal.DataHandler;
import com.hk.migration.db.craftsman.BizTeacherAccount;
import com.hk.migration.db.craftsman.BizTeacherInfo;
import com.hk.migration.db.hk.TchList;
import com.hk.migration.mapper.craftsman.BizTeacherClientMapper;
import com.hk.migration.mapper.craftsman.BizTeacherInfoMapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
@Slf4j
@AllArgsConstructor
@Component
public class TchListProcess implements CanalProcess {

    private final BizTeacherAccount bizTeacherAccount;

    private final BizTeacherInfoMapper bizTeacherInfoMapper;

    private final BizTeacherClientMapper bizTeacherClientMapper;

    @Override
    public boolean apply(String tableName, CanalEntry.EventType eventType) {
        return "tch_list".equals(tableName);
    }

    @Override
    public boolean processData(List<CanalData> beforeCanalDataList, List<CanalData> afterCanalDataList, CanalEntry.EventType eventType) {
        TchList tchList = DataHandler.convertToBean(afterCanalDataList, TchList.class);
        if (eventType == CanalEntry.EventType.INSERT){
            log.info("新增老师={}",tchList);
            BizTeacherInfo bizTeacherInfo = new BizTeacherInfo();

            return false;
        }

        if (eventType == CanalEntry.EventType.DELETE){
            log.info("删除老师={}",tchList);
            return false;
        }

        if (eventType == CanalEntry.EventType.UPDATE){
            log.info("修改老师={}",tchList);
            return false;
        }

        return false;
    }
}
